<template>
  <div class="sensitive">
    <span class="sensitive-text">{{ formatText }}</span>
    <span class="sensitive-btn" @click="showSensitive">查看</span>
    <InfoIcon content="点击后系统将记录行为" />
  </div>
</template>

<script>
import { supplierLogOperation } from '@/api/supplier';
import { contractLogOperation } from '@/api/legal';
export default {
  props: {
    formatText: {
      type: String,
      default: '****'
    },
    paramsObj: {
      type: Object,
      default: () => {
        return {};
      }
    },
    apiIndex: {
      type: Number,
      default: 0
    }
  },
  data() {
    return {
      apiList: {
        0: supplierLogOperation,
        1: contractLogOperation
      }
    };
  },
  methods: {
    showSensitive() {
      this.$emit('setSensitive');
      this.apiList[this.apiIndex](this.paramsObj).catch(err => console.error(err.message));
    }
  }
};
</script>

<style lang="scss" scoped>
  .sensitive {
    display: flex;
    align-items: center;
    .sensitive-btn {
      margin: 0 8px;
      color: #406eff;
      cursor: pointer;
    }
  }
</style>
